package com.ruoyi.district.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.district.Vo.ProVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.district.domain.FangProvince;
import com.ruoyi.district.service.IFangProvinceService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 省列表Controller
 * 
 * @author ruoyi
 * @date 2025-01-09
 */
@RestController
@RequestMapping("/province")
public class FangProvinceController extends BaseController
{
    @Autowired
    private IFangProvinceService fangProvinceService;

    /**
     * 查询省列表列表
     */
    //@RequiresPermissions("district:province:list")
    @GetMapping("/list")
    public TableDataInfo list(FangProvince fangProvince)
    {
        startPage();
        List<FangProvince> list = fangProvinceService.selectFangProvinceList(fangProvince);
        return getDataTable(list);
    }

    /**
     * 查询省列表列表
     */
    @GetMapping("/listPro")
    public TableDataInfo listPro(ProVo proVo)
    {
        startPage();
        List<FangProvince> list = fangProvinceService.selectFangProvinceListPro(proVo);
        return getDataTable(list);
    }


    /**
     * 导出省列表列表
     */
    @RequiresPermissions("district:province:export")
    @Log(title = "省列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FangProvince fangProvince)
    {
        List<FangProvince> list = fangProvinceService.selectFangProvinceList(fangProvince);
        ExcelUtil<FangProvince> util = new ExcelUtil<FangProvince>(FangProvince.class);
        util.exportExcel(response, list, "省列表数据");
    }

    /**
     * 获取省列表详细信息
     */
    @RequiresPermissions("district:province:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(fangProvinceService.selectFangProvinceById(id));
    }

    /**
     * 新增省列表
     */
    @RequiresPermissions("district:province:add")
    @Log(title = "省列表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FangProvince fangProvince)
    {
        return toAjax(fangProvinceService.insertFangProvince(fangProvince));
    }

    /**
     * 修改省列表
     */
    @RequiresPermissions("district:province:edit")
    @Log(title = "省列表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FangProvince fangProvince)
    {
        return toAjax(fangProvinceService.updateFangProvince(fangProvince));
    }

    /**
     * 删除省列表
     */
    @RequiresPermissions("district:province:remove")
    @Log(title = "省列表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(fangProvinceService.deleteFangProvinceByIds(ids));
    }
}
